import FirstStore from '../../../store/firstStore'
const barWidth = 10;
const symbolSize = [barWidth, 5];
const normalColor = "#94a1a9";
const fontSize = 10;
const datas = {
    legendData: ['未完成', '已完成'],
}
const ECharts = require('echarts/lib/echarts');
export const optionConfig = (dataX, dataYL, dataYB) => {
    return {
        animation: false, //去除加载时缓动动画
        legend: {
            show: true,
            selectedMode: true, //取消图例上的点击事件
            data: datas.legendData,
            textStyle: {
                color: '#fff'
            }
        },
        grid: {
            left: "3%",
            right: "4%",
            bottom: "3%",
            top: '23%',
            containLabel: true
        },
        tooltip: {
            trigger: "axis",
            axisPointer: {
                // 坐标轴指示器，坐标轴触发有效
                type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
            },
        },
        xAxis: {
            axisLine: {
                lineStyle: {
                    color: normalColor
                }
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                textStyle: {
                    color: normalColor,
                    fontSize: fontSize
                },
                margin: 20
            },
            splitLine: {
                show: false,
                lineStyle: {
                    type: "dashed",
                    color: normalColor
                }
            },
            data: FirstStore.processX,
        },
        // 左侧的y轴
        yAxis: [{
            type: 'category',
            color: normalColor,
            axisTick: {
                show: false
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: normalColor
                }
            },
            axisLabel: {
                show: true,
                formatter: '{value}',
                textStyle: {
                    color: normalColor,
                    fontSize: fontSize
                }
            },
            axisLine: {
                show: false,
                lineStyle: {
                    color: normalColor
                }
            },
            data: [0, '1个月', '3个月', '6个月', '1年']

        },
        // 右侧的y轴
        {
            type: 'category',
            // name: "万千瓦时/万元",
            nameTextStyle: {
                fontSize: fontSize
            },
            color: normalColor,
            axisTick: {
                show: false
            },
            splitLine: {
                show: false,
            },
            axisLabel: {
                show: false,
                formatter: '{value}',
                textStyle: {
                    color: normalColor,
                    fontSize: fontSize
                }
            },
            axisLine: {
                show: false,
                lineStyle: {
                    color: normalColor
                }
            },
            data: [0, '1个月', '3个月', '6个月', '1年']

        }
        ],
        series: [{ // 绿色柱子
            tooltip: {
                show: true
            },
            name: datas.legendData[0],
            type: 'bar',
            barWidth: barWidth, //柱子宽度
            barGap: 0.5, //柱子之间间距
            emphasis: {
                itemStyle: { //填充部分鼠标移上去颜色
                    color: new ECharts.graphic.LinearGradient(
                        0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(211, 189, 10,0.8)'
                        },
                        {
                            offset: 1,
                            color: 'rgba(224, 147, 0,0.8)'
                        }
                    ]),
                }
            },
            label: {
                show: false,// 柱状图上面的文字
                position: "top",
                padding: 10,
                textStyle: {
                    fontSize: fontSize
                }
            },
            itemStyle: {
                normal: {
                    color: new ECharts.graphic.LinearGradient(
                        0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(211, 189, 10,0.8)'
                        },
                        {
                            offset: 1,
                            color: 'rgba(224, 147, 0,0.8)'
                        }
                    ]),
                    borderWidth: '1',
                    borderColor: 'rgba(211, 189, 10,0.8)',
                }
            },
            data: FirstStore.processY1,
            legendHoverLink: false,
        }, {
            // 红色柱子
            name: datas.legendData[1],
            type: 'bar',
            // stack: 1,
            barWidth: barWidth, //柱子宽度
            barGap: 0.5, //柱子之间间距
            yAxisIndex: 1, //选择第二个y轴 不写的话 双y轴无法实现
            emphasis: {
                itemStyle: { //左侧未填充部分鼠标移上去颜色
                    color: new ECharts.graphic.LinearGradient(
                        0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(6, 212, 255,0.8)'
                        },
                        {
                            offset: 1,
                            color: 'rgba(0, 129, 255,0.8)'
                        }
                    ]),
                    barBorderColor: 'rgba(0, 129, 255,0.8)'
                }
            },
            label: {
                show: false,
                position: "top",
                padding: 10,
                textStyle: {
                    fontSize: fontSize
                }
            },
            itemStyle: {
                normal: {
                    color: new ECharts.graphic.LinearGradient(
                        0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(6, 212, 255,0.8)'
                        },
                        {
                            offset: 1,
                            color: 'rgba(0, 129, 255,0.8)'
                        }
                    ]),
                    barBorderColor: 'rgba(0, 129, 255,0.8)',
                }
            },
            data: FirstStore.processY2,
        }
        ]
    };
}
